﻿import QtQuick 2.0
import QtQuick.Controls 2.12

// 原来这里放的是word的预览，现在改成excel形式的了，就放点实验信息吧

Rectangle {

    function refreshInfo(){
        expInfo = CPrinter.getExpInfo()
        info1 = []
        info1.push(expInfo["ExpName"])
        info1.push(expInfo["ExpType"])
        info1.push(expInfo["ExpStartTime"].split(" ")[0])
        info1.push(expInfo["EquName"])
        info1Changed()
        info2 = []
        info2.push(expInfo["ConsumableName"])
        info2.push(expInfo["ConsumableCode"])
        info2.push(expInfo["SampleHalfLife"])
        info2.push(expInfo["HalfLifeDate"])
        info2Changed()
        info3 = []
        info3.push(expInfo["Memo"])

        logInfo = CPrinter.getLogInfo()
        scrollView.contentItem.contentY = 0

        imageChrom.source = "image://chromImage/" + Math.random()
    }

    // 用于外面打印报告，ExpStartTime作为报告名了
    function getExpStartTime(){
        return expInfo["ExpStartTime"]
    }


    property real marginWidth: 0
    property var title1: ["实验名称", "实验类别", "实验日期", "设备名称"]
    property var info1: ["20251030001", "G90", "2529年84月32日", "EZ Studio"]
    property var title2: ["耗材名称", "耗材编号", "纯化样品\n半衰期", "十个半衰期后安全处理日期"]
    property var info2: ["15F003", "114514", "16min", "2504年39月13日"]
    property var title3: ["描述"]
    property var info3: [""]
    property var expInfo: []
    property var logInfo: []
    clip: true

    ScrollView{
        id: scrollView
        x: marginWidth; y: marginWidth
        width: parent.width - 2*marginWidth
        height: parent.height - 2*marginWidth
        Column{
            width: parent.width
            // 实验基本信息 --------------------------------------------------------------------
            Rectangle{
                height: 40*dp; width: parent.width
                color: "#DDD"
                border.color: "#BBB"
                Text{
                    x: 12*dp
                    text: qsTr("基本信息")
                    font.pixelSize: config.fontsize_a
                    font.bold: true
                    anchors.verticalCenter: parent.verticalCenter
                }
            }
            // 第一行信息
            Row{
                height: 44*dp; width: parent.width - 2
                x: 1
                Repeater{
                    anchors.fill: parent
                    model: title1.length
                    ReportInfo_InfoItem{
                        height: parent.height; width: parent.width / title1.length
                        title: title1[index]
                        info: info1[index]
                    }
                }
            }
            Rectangle{ height: 1; width: parent.width; color: "#BBB" }
            // 第二行信息
            Row{
                height: 44*dp; width: parent.width - 2
                x: 1
                Repeater{
                    anchors.fill: parent
                    model: title2.length
                    ReportInfo_InfoItem{
                        height: parent.height; width: parent.width / title2.length
                        title: title2[index]
                        info: info2[index]
                    }
                }
            }
            Rectangle{ height: 1; width: parent.width; color: "#BBB" }
            // 第三行信息
            Row{
                height: 44*dp; width: parent.width - 2
                x: 1
                Repeater{
                    anchors.fill: parent
                    model: title3.length
                    ReportInfo_InfoItem{
                        height: parent.height; width: parent.width / title3.length
                        title: title3[index]
                        info: info3[index]
                    }
                }
            }
            // 能谱图
            Rectangle{
                height: 40*dp; width: parent.width
                color: "#DDD"
                border.color: "#BBB"
                Text{
                    x: 12*dp
                    text: qsTr("能谱图")
                    font.pixelSize: config.fontsize_a
                    font.bold: true
                    anchors.verticalCenter: parent.verticalCenter
                }
            }
            Item{
                height: 400*dp; width: parent.width
                Image{
                    id: imageChrom
                    height: 380*dp; width: 520*dp
                    anchors.centerIn: parent
                    source: "image://chromImage"
                }
            }
            // 实验流程
            Rectangle{
                height: 40*dp; width: parent.width
                color: "#DDD"
                border.color: "#BBB"
                Text{
                    x: 12*dp
                    text: qsTr("实验流程")
                    font.pixelSize: config.fontsize_a
                    font.bold: true
                    anchors.verticalCenter: parent.verticalCenter
                }
            }
            ReportInfo_LogItem{
                width: parent.width
                height: 30*dp
                logData: ["时间", "步骤号", "动作", "用时(ms)", "状态"]
            }
            Repeater{
                width: parent.width
                model: logInfo.length
                ReportInfo_LogItem{
                    width: parent.width
                    height: 30*dp
                    logData: logInfo[index]
                }
            }
            Item{   // 占位
                height: 10*dp; width: parent.width
            }
        }
    }


}
